CREATE CONVERSION
CREATE CONVERSION — Define a new encoding conversion
Synopsis
CREATE [ DEFAULT ] CONVERSION name
FOR source_encoding TO dest_encoding FROM function_name
Description
CREATE CONVERSION defines a new conversion between two character set encodings.
A conversion marked as DEFAULT will be automatically used for encoding conversion between the client and the server. To support this usage, two conversions must be defined (from encoding A to B and from encoding B to A). To create a conversion, you must have EXECUTE privilege on the function and CREATE privilege on the target schema.
Parameters
DEFAULT
The DEFAULT clause indicates that this conversion is the default conversion from the source encoding to the destination encoding. There should be only one default conversion for each encoding pair in a schema.
name
The name of the conversion, which can be schema-qualified. If not schema-qualified, the conversion is defined in the current schema. The conversion name must be unique within a schema.
source_encoding
The source encoding name.
dest_encoding
The destination encoding name.
function_name
The function used to perform the conversion. The function name can be schema-qualified. If not, the function will be looked up in the path. The function must have the following signature:
conv_proc(
integer, -- source encoding ID
integer, -- destination encoding ID
cstring, -- source string (null-terminated C string)
internal, -- destination (filled with a null-terminated C string)
integer -- source string length
) RETURNS void;
Notes
Neither the source encoding nor the destination encoding can be SQL_ASCII, because the server's behavior is hard-wired for cases involving the SQL_ASCII "encoding".
Use DROP CONVERSION to remove user-defined conversions.
The privileges required to create a conversion may be changed in future releases.
Examples
# Create a conversion from encoding UTF8 to LATIN1 using myfunc:
CREATE CONVERSION myconv FOR 'UTF8' TO 'LATIN1' FROM myfunc;